import request from '@/api/axios'
import {AxiosPromise} from 'axios'
import {DataRes, Paging} from '@/api/config'

// 体检大类编码 categoryCode
// 体检大类名称 categoryName
// 排序	sort
// 检查类型 checkType checkTypeName

//体检大类分页查询数据定义
export interface GetCategoryList extends Paging{
  categoryName?:string|null,
  categoryCode?:string|null,
  checkType?:string|null,
  sort?:string|null,
  checkTypeName?:string|null
}

// 搜索数据定义
export interface SearchCategoryFromData{
  categoryName?:string|null,
  checkType?:string|null,
}

//表头按钮定义
export type TableOperation='add'

// 体检大类基本信息
export interface BaseCategoryInfor{
  categoryName:string,
  categoryCode:string,
  sort:string|null,
  checkType:string,
  checkTypeName:string
}

//体检大类信息
export interface CategoryInfor extends BaseCategoryInfor{
  id:number
}

export type CategoryFormInfor = Partial<CategoryInfor>

export interface CategoryInforList {
  size:number
  total:number
  records:Array<CategoryInfor>
}
//获取体检大类管理列表事件
export const getCategoryList = (params:GetCategoryList):AxiosPromise<DataRes<CategoryInforList>> => {
  return request({
    url:'/api/inspectCategory/page',
    method:'get',
    params
  })
}

//新增体检大类信息事件
export const addCategoryInfor = (data:CategoryFormInfor):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/inspectCategory/add',
    method:'post',
    data
  })
}

//保存修改体检大类信息事件
export const saveCategoryInfor = (data:CategoryFormInfor):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/inspectCategory/update',
    method:'post',
    data
  })
}

// 删除体检大类信息事件
export const deleteCategory = (data:Array<string>):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/inspectCategory/remove',
    method:'post',
    data
  })
}

/**
 * @description:  获取所有体检大类
 * @param {*} AxiosPromise
 * @return {*}
 */
export const getAllCategoryList = ():AxiosPromise<DataRes<Array<CategoryInfor>>> => {
  return request({
    url:'/api/inspectCategory/list',
    method:'get'

  })
}